stack segment 
         db 64 dup('stack...')
stack ends
datarea segment 
mus_freq dw 2 dup(262,294,330,262),330,349,392
         dw 330,349,392,2 dup(392,440,392,349,330,262)
         dw 2 dup(294,196,262)
         dw -1
mus_time dw 3 dup(50),25,25,50,25,25,100
            dw 2 dup(50,50,25,25),100
            dw 3 dup(50,25,25),100
datarea ends
code segment 
     assume cs:code,ss:stack,ds:datarea
music proc far
     push ds
     sub ax,ax
     push ax
     
     mov ax,datarea
     mov ds,ax
     lea si,mus_freq
     lea bp,ds:mus_time
freq:
     mov di,[si]
     cmp di,-1
     je end_mus
     mov bx,ds:[bp]
     call soundf
     add si,2
     add bp,2
     jmp freq
end_mus:
      ret
music endp
soundf proc near
     push ax
     push bx
     push cx
     push dx
     push di
     mov bx,8000
     mov al,0b6h
     out 43h,al
     mov dx,12h
     mov ax,348Ch
     div di
     out 42h,al
     mov al,ah
     out 42h,al
     in al,61h
     mov ah,al
     or al,3
     out 61h,al
wait1:
     mov cx,8000
delay:
     loop delay
     dec bx 
     jnz wait1
     mov al,ah
     out 61h,al
     pop di
     pop dx
     pop cx
     pop bx
     pop ax
     ret
soundf endp
code ends
end music